#define _CRT_SECURE_NO_WARNINGS 1
#include "Heap.h"

void test1()
{
	Heap hp;
	int a[] = {1,3,5,2,4,6,7,9,8};
	HeapInit(&hp);
	for(int i = 0;i < sizeof(a) / sizeof(int);i++)
	{
		HeapPush(&hp,a[i]);
	}
	
	while (!HeapEmpty(&hp))
	{
		printf("%d ",HeapTop(&hp));
		HeapPop(&hp);
	}
	printf("\n");

}
void HeapSort()
{
	int a[] = { 1,3,5,2,4,6,7,9,8 };
	int n = sizeof(a) / sizeof(int);
	for (int i = 1; i < n; i++)
	{
		AdjustUp(a,i);
	}
	int end = n - 1;
	while (end > 0)
	{
		swap(&a[0],&a[end]);
		AdjustDown(a,end,0);
		--end;
	}
}
int main()
{
	/*test1();*/
	HeapSort();
	return 0;
}